﻿using System;
using YArchitech.Controls;
using YArchitech.LIB;

namespace YArchitech.Temp
{
	internal static class YJKTextBoxExtern
	{
		public static void SetValue(this YJKTextBox tb, double doubleValue)
		{
			tb.Text = StringTools.DoubleToString(doubleValue, 3);
		}

		public static double GetValue(this YJKTextBox tb, double defValue = 0.0)
		{
			double result = defValue;
			if (!double.TryParse(tb.Text, out result))
			{
				result = defValue;
			}
			return result;
		}

		public static void SetValue(this YJKComboBox combo, int intValue)
		{
			combo.Text = intValue.ToString();
		}

		public static int GetValue(this YJKComboBox combo, int defValue = 0)
		{
			int result = defValue;
			if (!int.TryParse(combo.Text, out result))
			{
				result = defValue;
			}
			return result;
		}
	}
}
